import request from '@/utils/request'
import MODULE from '@/utils/module'

export function login(userName, password) {
  const data = {
    userName,
    password
  }
  return request({
    url: MODULE.MODULE.admin + '/login',
    method: 'post',
    params: {},
    data: data,
    transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
      data = JSON.stringify(data)
      return data
    }],
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function logout() {
  return request({
    url: MODULE.MODULE.admin + '/logout',
    method: 'post'
  })
}

export function getUserInfo(userId, organId) {
  const data = {
    userId,
    organId
  }
  return request({
    url: MODULE.MODULE.admin + '/getUserInfo',
    method: 'post',
    params: {},
    data: data,
    transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
      data = JSON.stringify(data)
      return data
    }],
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
